package com.yunxi.controller.order;

import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.CurrentUser;
import com.yunxi.core.web.LoginInfo;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.order.pojo.ExperienceCarQuotaVO;
import com.yunxi.order.service.ExperienceCarQuotaDubboService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 体验车配额表 前端控制器
 * </p>
 *
 * @author
 * @since 2019-08-20
 */
@RestController
@RequestMapping("/admin/experiencecarquota")
@Api(tags = "pms:experiencecarquota", description = "体验车配额表接口")
public class ExperienceCarQuotaController {
   private static final Logger logger = LoggerFactory.getLogger(ExperienceCarQuotaController.class);

   @Autowired
   ExperienceCarQuotaDubboService experienceCarQuotaDubboService;

   @GetMapping("/page")
   @ApiOperation(value = "查询体验车配额分页")
   public ApiResult page(ExperienceCarQuotaVO experienceCarQuotaVO, Integer pageNum, Integer pageSize) throws Exception {
      return ResponseUtil.ok(experienceCarQuotaDubboService.findPageByVO(experienceCarQuotaVO, pageNum, pageSize));
   }

   @GetMapping("/list")
   @ApiOperation(value = "查询体验车配额列表")
   public ApiResult list(ExperienceCarQuotaVO experienceCarQuotaVO) throws Exception {
      return ResponseUtil.ok(experienceCarQuotaDubboService.listByVo(experienceCarQuotaVO));
   }

   @GetMapping("/load")
   @ApiOperation(value = "读取单个体验车配额")
   public ApiResult load(ExperienceCarQuotaVO experienceCarQuotaVO, @CurrentUser LoginInfo loginInfo) throws Exception {
      return ResponseUtil.ok(experienceCarQuotaDubboService.getById(experienceCarQuotaVO.getQuotaId()));
   }

   @PostMapping("/save")
   @ApiOperation(value = "保存体验车配额信息")
   public ApiResult save(@RequestBody ExperienceCarQuotaVO experienceCarQuotaVO, @CurrentUser LoginInfo loginInfo) throws Exception {
      experienceCarQuotaDubboService.saveOrUpdate(experienceCarQuotaVO);
      return ResponseUtil.ok("success");
   }

   @PostMapping("/del")
   @ApiOperation(value = "删除体验车配额")
   public ApiResult del(@RequestBody List<ExperienceCarQuotaVO> experienceCarQuotaVOList) throws Exception {
      experienceCarQuotaDubboService.removeByListVo(experienceCarQuotaVOList);
      return ResponseUtil.ok("success");
   }

/*@PostMapping("/export")
@ApiOperation(value = "导出excel")
public Object export(@RequestParam Map<String,Object> params) throws Exception {
return ResponseUtil.ok(experienceCarQuotaDubboService.findMapByList(params));
}*/
}
